package Day19;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String s1 = in.nextLine();
        String s2 = in.nextLine();

        

    }

    public static void main0(String[] args) {

        Scanner in = new Scanner(System.in);

        while (in.hasNextInt()) {
            int n = in.nextInt();
            if (n == 0) {
                break;
            } else {
                int ret = bottles(n);
                System.out.println(ret);
            }

        }
    }

    public static int bottles (int n) {

        if (n < 3) {
            return 0;
        } else {

            int sum = 0;
            int emptys = n;
            int bottles = 0;

            while (emptys >= 3) {
                //空瓶子兑换
                bottles = emptys / 3;
                //喝了的
                sum += bottles;
                //空瓶子减少
                emptys %= 3;
                //空瓶子增加
                emptys += bottles;
            }

            if (emptys == 2) {
                sum++;
            }
            return sum;

        }
    }

}
